<?php
$title = 'Problemas Disponibles';
$this->headTitle($title);
?>
<div class="content">
    <h1><?php echo $this->escapeHtml($title); ?></h1>        
    <div style="margin-top: 20px;">
        <center>
            <table class="table-bordered" style="width: 80%">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Author</th>
                        <th>Rating</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    foreach ($this->paginator as $problem) :
                        $rating = $problem['solutions'] > 0 ? round(($problem['accepted_solutions'] / $problem['solutions'] * 100), 1): 0
                        ?>
                        <tr>
                            <td><?php echo $this->escapeHtml($problem['problem_id']); ?></td>
                            <td style="min-width: 100px">
                                <a href="<?php echo $this->url('problem', array('action' => 'display', 'id' => $problem['problem_id'])); ?>"><?php echo $this->escapeHtml($problem['problem_name']); ?></a>
                            </td>
                            <td><?php echo $this->escapeHtml($problem['problem_author']); ?></td>
                            <td style="width: 150px;">
                                <div style="width:150px;height:15px;background-color:#ff0000;position:relative">
                                    <div style="width:<?php echo $rating ?>%;height:100%;background-color:#00ff00;"></div>
                                    <div style="width:100%;height:100%;text-align:center;position:absolute;top:-2px;left:0;font-size:13;font-family:Tahoma,Verdana,Arial,sans-serif;"><?php echo $rating ?>%</div>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </center>
    </div>

    <?php
    echo $this->paginationControl($paginator, 'Sliding', 'problem-paginator');
    ?>
</div>